home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / T U R B O Language / Turbo C Tools v6.0 / INCLUDE / BEDIT.H next >
Encoding:
C/C++ Source or Header  |  1989-03-31  |  8.3 KB  |  213 lines

  1. /**
  2. *
  3. *  BEDIT.H    Header file for Turbo C TOOLS Field Editing Functions
  4. *
  5. *  Version    6.00 (C)Copyright Blaise Computing Inc.  1988
  6. *
  7. **/
  8.  
  9.  
  10. #ifndef DEF_BEDIT          /* Prevent second reading of        */
  11. #define DEF_BEDIT   1          /* these definitions.         */
  12.  
  13. #include <bkeybrd.h>
  14. #include <bscreens.h>
  15. #include <bwindow.h>
  16.  
  17.  
  18. /********************************************************************/
  19. /* Definitions of data types.                        */
  20. /********************************************************************/
  21.  
  22. typedef enum                   /* ED_ACTION:            */
  23. {                       /*   values for the EDIT_KEY */
  24.                        /*   action field.        */
  25.     ED_NULL,                   /* No action.            */
  26.     ED_ABORT,                   /* Quit with no edit.        */
  27.     ED_BEEP,                   /* Sound the system speaker. */
  28.     ED_ATTR,                   /* Alter attributes.        */
  29.     ED_ASCII,                   /* Display the character.    */
  30.     ED_LEFT,                   /* Move left.            */
  31.     ED_RIGHT,                   /* Move right.            */
  32.     ED_UP,                   /* Move up one line.        */
  33.     ED_DOWN,                   /* Move down one line.        */
  34.     ED_FRONT,                   /* Move to front of buffer.  */
  35.     ED_END,                   /* Move to end of buffer.    */
  36.     ED_TEXT_END,               /* Move to last non-whitesp. */
  37.     ED_WRAP,                   /* Word wrap the buffer.     */
  38.     ED_REDUCE,                   /* Reduce whitespace.        */
  39.     ED_NEXT_WORD,               /* Move to next word.        */
  40.     ED_PREV_WORD,               /* Move to previous word.    */
  41.     ED_BEGIN_WORD,               /* Move to start of word.    */
  42.     ED_END_WORD,               /* Move to end of word.        */
  43.     ED_NEXT_WHITE,               /* Move to next/previous     */
  44.     ED_PREV_WHITE,               /*   whitespace character.   */
  45.     ED_NEXT_NONWHITE,               /* Move to next/previous non-*/
  46.     ED_PREV_NONWHITE,               /*   whitespace character.   */
  47.     ED_DELETE,                   /* Delete current character. */
  48.     ED_RUBOUT,                   /* Move left and delete char.*/
  49.     ED_DELLEFT,                /* Delete char to left.        */
  50.     ED_DEL_WORD,               /* Delete a word.        */
  51.     ED_CLEAR,                   /* Clear the entire buffer.  */
  52.     ED_CLEAREOL,               /* Clear to end of line.     */
  53.     ED_CLEAREOB,               /* Clear to end of buffer.   */
  54.     ED_INSERT,                   /* Insert mode.            */
  55.     ED_REPLACE,                /* Replace (not insert) mode.*/
  56.     ED_INSTOGGLE,               /* Toggle insert mode.        */
  57.     ED_UNDO,                   /* Recover previous buffer.  */
  58.     ED_TRANSMIT,               /* Finish edit.            */
  59.     ED_INVALID_ACTION               /* Invalid edit action.        */
  60. } ED_ACTION;
  61.  
  62.  
  63. typedef struct
  64. {                       /* ED_ACTION_LIST structure: */
  65.     int         num_actions;       /*   number of action codes, */
  66.     ED_ACTION        *pactions;           /*   array of action codes.  */
  67. } ED_ACTION_LIST;
  68.  
  69.  
  70. typedef struct
  71. {                       /* ED_KEY structure:        */
  72.     ED_ACTION_LIST  edit_actions;      /*   edit actions, key        */
  73.     KEY_SEQUENCE    key_sequence;      /*   sequence and attribute  */
  74.     int         attribute;           /*   for edit key.        */
  75. } ED_KEY;
  76.  
  77.  
  78. typedef struct ed_list               /* ED_LIST structure:        */
  79. {                       /*   ED_KEY & pointers to    */
  80.     ED_KEY        edit_key;           /*   next and last items in  */
  81.     struct ed_list  *pnext;           /*   edit key list.        */
  82.     struct ed_list  *pprev;
  83. } ED_LIST;
  84.  
  85.  
  86. typedef struct                   /* ED_BUFFER structure:        */
  87. {                       /*   edit buffer passed to   */
  88.                        /*   edbuffer().         */
  89.     char        *pbuffer;           /* Edit buffer.            */
  90.     DIM         dimensions;        /* Dimensions of field.        */
  91.     int         attribute;           /* Display attributes.        */
  92.     int         buffer_size;       /* Maximum length of buffer. */
  93.     int         cursor_pos;        /* Edit position in buffer.  */
  94.     int         data_end;           /* End of data in buffer.    */
  95.     unsigned int    control_flags;     /* Flags for edbuffer/edbase.*/
  96. } ED_BUFFER;
  97.  
  98.  
  99. typedef struct                   /* ED_CONTROL structure:     */
  100. {                       /*   position & info for an  */
  101.                        /*   edit buffer.        */
  102.     LOC         ul_corner;           /* Upper left corner.        */
  103.     DIM         dimensions;        /* Dimensions of field.        */
  104.     int         attribute;           /* Display attributes.        */
  105.     CUR_TYPE        replace_cursor;    /* Cursor size for replace   */
  106.     CUR_TYPE        insert_cursor;     /*   and insert modes.        */
  107.     PKEY_CONTROL    control_function;  /* Key control function.     */
  108.     unsigned int    control_flags;     /* edfield() control flags.  */
  109. } ED_CONTROL;
  110.  
  111.  
  112. typedef struct
  113. {
  114.     int       action_code;           /* Single action code.        */
  115.     KEY_SEQUENCE  key_sequence;        /* Key sequence for edit key.*/
  116. } ED_DEF_KEY;
  117.  
  118.  
  119. typedef int  cdecl (*PED_RET_FUNC)(void *, CUR_INFO *, const LOC *,
  120.                    int, int);
  121. typedef int  cdecl (*PED_SET_FUNC)(void *, int, CUR_TYPE *, int, int);
  122. typedef void cdecl (*PED_WRITE_FUNC)(void *, int, int, int, int,
  123.                      const char *, int, int, int);
  124.  
  125.  
  126. /********************************************************************/
  127. /* User Macros.                             */
  128. /********************************************************************/
  129.  
  130. #define edfield(pinitstr,pretstr,target_size,pfield_control,pfinal) \
  131.     (edbase(NIL, (pinitstr), (pretstr), (target_size),        \
  132.         (pfield_control), (pfinal), edretinf, edsetcur,     \
  133.         edwrrect))
  134.  
  135.         /* Edit mode constants for control_flags member of  */
  136.         /* the ED_CONTROL structure.                */
  137. #define ED_LEFTJUST    0x8000           /* Left justify upon exit.   */
  138. #define ED_CENTERJUST    0x4000           /* Center justify upon exit. */
  139. #define ED_RIGHTJUST    0x2000           /* Right justify upon exit.  */
  140. #define ED_ZERO_FILL    0x1000           /* Zero fill.            */
  141. #define ED_BEEP_END    0x0800           /* Beep when at end of field.*/
  142. #define ED_AUTOSKIP    0x0400           /* Transmit at end of field. */
  143. #define ED_INSERT_MODE    0x0200           /* Start in INSERT mode.     */
  144. #define ED_WORD_WRAP    0x0100           /* Word wrap buffer.        */
  145.  
  146.  
  147.  
  148. /********************************************************************/
  149. /* Global variables                            */
  150. /********************************************************************/
  151.  
  152. extern ED_LIST        *b_pkey_root;      /* Edit key list head.        */
  153. extern int         b_pkeys_init;     /* Non-zero if edit key list */
  154.                        /*   has been initialized.   */
  155.  
  156. extern ED_DEF_KEY    b_defkeys[];      /* Default edit key records. */
  157.  
  158.  
  159.  
  160. /********************************************************************/
  161. /* Error codes.                             */
  162. /********************************************************************/
  163.  
  164. #define ED_NO_ERROR        WN_NO_ERROR
  165. #define ED_NO_MEMORY        WN_NO_MEMORY
  166. #define ED_ILL_DIM        WN_ILL_DIM
  167. #define ED_NO_KEY        300
  168. #define ED_KEY_EXISTS        301
  169. #define ED_USER_ABORT        302
  170.  
  171.  
  172. /********************************************************************/
  173. /* User function declarations.                        */
  174. /********************************************************************/
  175.  
  176. int    cdecl edinitky(void);      /* Initialize edit key list.        */
  177.                   /*                    */
  178. ED_KEY *cdecl edretkey(const      /* Return an edit key record from */
  179.          KEY_SEQUENCE *); /* the edit key list.         */
  180.                   /*                    */
  181. int    cdecl edchgkey(       /* Change an edit key record in   */
  182.         const          /* the edit list.            */
  183.         KEY_SEQUENCE *,   /* the edit list.            */
  184.         const          /*                    */
  185.         ED_ACTION_LIST *);/*                    */
  186.                   /*                    */
  187. int    cdecl edremkey(const      /* Delete an edit key record in   */
  188.         KEY_SEQUENCE *);  /* the edit list.            */
  189.                   /*                    */
  190. void    cdecl edzapkey(void);      /* Release the entire edit list.  */
  191.                   /*                    */
  192. ED_ACTION cdecl edbuffer(      /* Edit a buffer.            */
  193.         ED_BUFFER *,      /*                    */
  194.         const ED_KEY *);  /*                    */
  195.                   /*                    */
  196.  
  197. /********************************************************************/
  198. /* Internal function declarations.                    */
  199. /********************************************************************/
  200.  
  201. int    cdecl edretinf(void *, CUR_INFO *, const LOC *, int, int);
  202. int    cdecl edsetcur(void *, int, CUR_TYPE *, int, int);
  203. void    cdecl edwrrect(void *, int, int, int, int, const char *,
  204.                int, int, int);
  205. int    cdecl edbase(void *, const char *, char *, int,
  206.              const ED_CONTROL *, KEY_SEQUENCE *, PED_RET_FUNC,
  207.              PED_SET_FUNC, PED_WRITE_FUNC);
  208. void    cdecl edwrap(ED_BUFFER *);
  209. void    cdecl edreduce(ED_BUFFER *);
  210.  
  211.  
  212. #endif                  /* Ends "#ifndef DEF_BEDIT"       */
  213.